From dc4950a33b5ae1a2f7ca46e3b667ab9f50b9d850 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 3 Jun 2015 13:04:42 -0700 Subject: [PATCH] Implemented getAllAcquiredJobs in JobQueueDB Change-Id: Ie9f0b9357b365f8bddd1f2fdcac11dec29aec876 --- includes/jobqueue/JobQueueDB.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/includes/jobqueue/JobQueueDB.php b/includes/jobqueue/JobQueueDB.php index 74edef3805..3dc36bd58b 100644 --- a/includes/jobqueue/JobQueueDB.php +++ b/includes/jobqueue/JobQueueDB.php @@ -558,19 +558,35 @@ class JobQueueDB extends JobQueue { * @return Iterator */ public function getAllQueuedJobs() { + return $this->getJobIterator( array( 'job_cmd' => $this->getType(), 'job_token' => '' ) ); + } + + /** + * @see JobQueue::getAllAcquiredJobs() + * @return Iterator + */ + public function getAllAcquiredJobs() { + return $this->getJobIterator( array( 'job_cmd' => $this->getType(), "job_token > ''" ) ); + } + + /** + * @param array $conds Query conditions + * @return Iterator + */ + protected function getJobIterator( array $conds ) { $dbr = $this->getSlaveDB(); try { return new MappedIterator( - $dbr->select( 'job', self::selectFields(), - array( 'job_cmd' => $this->getType(), 'job_token' => '' ) ), - function ( $row ) use ( $dbr ) { + $dbr->select( 'job', self::selectFields(), $conds ), + function ( $row ) { $job = Job::factory( $row->job_cmd, Title::makeTitle( $row->job_namespace, $row->job_title ), - strlen( $row->job_params ) ? unserialize( $row->job_params ) : false + strlen( $row->job_params ) ? unserialize( $row->job_params ) : array() ); $job->metadata['id'] = $row->job_id; $job->metadata['timestamp'] = $row->job_timestamp; + return $job; } ); -- 2.20.1